//
//  ZWVisitorController.swift
//  weiboXue
//
//  Created by xue-iOS-work on 16/8/30.
//  Copyright © 2016年 iOS-work. All rights reserved.
//

import UIKit

class ZWVisitorController: UITableViewController {
    // 定义一个全局的属性 标记是否已经登录
    var userLogin = false
    
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: nil, title: "注册", style: .plain, target: self, action: #selector(clickZhuCeBtn))
        navigationItem.rightBarButtonItem = UIBarButtonItem(imageName: nil, title: "登录", style: .plain, target: self, action: #selector(clickLoginBtn))
    }
    // 视图加载的方法
    override func loadView() {
        if userLogin==false {
            // 展示新视图
            let vi = visitorView
            // 赋值
            view = vi
            
        }else
        {
            super.loadView()
        }
    }
    //-- 懒加载视图
    lazy var visitorView: ZWVisitorView =  {
        let visitor  = ZWVisitorView()
        return visitor
    }()
    //---- 点击注册按钮
    func clickZhuCeBtn() {
        let vc = ZWRegisterController()
        let nav = ZWNavigationController(rootViewController: vc)
        //modal
        present(nav, animated: true, completion: nil)
        print("点击了注册按钮")
    }
    //---- 点击登录按钮
    func clickLoginBtn() {
        let vc = ZWLoginController()
        let nav = ZWNavigationController(rootViewController: vc)
        //modal
        present(nav, animated: true, completion: nil)
        
        print("点击了登录按钮")
        
    }
}
